/**
 * Project Name:cnsy-url-short-service
 * File Name:GlobalExceptionHandler.java
 * Package Name:cn.cnsy123.shorturls.api.advice 
 * Date: 2020年4月15日-下午4:27:04
 * Copyright (c) 2020, yangpengfei@360@126.com All Rights Reserved. 
 *
 */

package cn.cnsy123.shorturls.api.advice;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.NoHandlerFoundException;

/**
 * ClassName: GlobalExceptionHandler
 * 
 * @author yangpengfei
 * @date 2020年4月15日-下午4:27:04
 * @version 1.0
 * @since JDK 1.7
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    
    @ResponseStatus(code = HttpStatus.NOT_FOUND)
    public void noHandlerFound(NoHandlerFoundException e,HttpServletRequest request, HttpServletResponse response) throws IOException{
        response.sendRedirect("/error/404");
    }

}
